﻿package smooth.core.object.flickrComponent.contextualMenu.flickrImageComponent {
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.*;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.text.AntiAliasType;
	import flash.filters.*;
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.net.URLRequest;
	
	public class FlickrImageContextualMenu extends Sprite {
		[Embed(source="Arial.ttf", fontFamily="myFont")] 
		public var myFont:Class;
		
		private var initialWidth:int;
		private var initialHeight:int;
		private var initialPosX:int;
		private var initialPosY:int;
		private var initialColor:int;
		private var currentButtonAngle:Number;
		private var closeIcon:Bitmap;
		private var internalRadiusMenu:int;
		private var radiusMenu:int;
		private var backgroundDrawing:Shape = new Shape();	
		
		
		public function FlickrImageContextualMenu(posX:int, posY:int, color:int, radius:int) {
			// Init des attributs de l'objet
			this.initialPosX = posX;
			this.initialPosY = posY;
			this.initialColor = color;
			this.radiusMenu = radius;
			this.internalRadiusMenu = 60;
			this.currentButtonAngle = 2*Math.PI/16;
			// Init des visuels du composant			
			initGraphics();
			// Init des events du composant
			initEvents();	
			// Init des process du composant
			initProcess();
		}
		
		private function initGraphics():void {
			this.x = this.initialPosX;
			this.y = this.initialPosY;
		}
		
		private function initProcess():void {
		}
		
		private function initEvents():void {
		}
		
		public function addButton(o:Object):void {
			if (o != null) {
				var p:Number = 2 * Math.PI / 16;
				o.x = this.radiusMenu*Math.cos(this.currentButtonAngle-p);
				o.y = -this.radiusMenu*Math.sin(this.currentButtonAngle-p);
				o.initialPosX = o.x;
				o.initialPosY = o.y;
				o.t.rotation = -(this.currentButtonAngle-p) * 180/Math.PI
				this.addChild(o);
				this.currentButtonAngle = this.currentButtonAngle-p;
			}
		}
		
	}
	
}